<!DOCTYPE html>
<html>
<!-- 微信分享Demo -->
<head>
    {include file="public/header" /}
    <link rel="stylesheet" type="text/css" href="/index/css/userMyCard.css" />
	<!-- 微信分享js 需要到官网下载 -->
	<script src="/static/js/jweixin-1.2.0.js" type="text/javascript"></script>
	<script>
		wx.config({
			  debug: false,
			  appId: "{$appId}",  //填写appid
			  timestamp: 1421142450,
			  nonceStr: '9hKgyCLgGZOgQmEI',
			  signature: '{$signature}', //填写签名
			  jsApiList: [
				'onMenuShareTimeline',
				'onMenuShareAppMessage',
				'onMenuShareQQ',
			  ]
		});
		wx.ready(function(){
		    //分享到朋友圈
			wx.onMenuShareTimeline({
			  title: '{$res.us_trueName}的名片', // 分享标题
			  link: '', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一�?
			  imgUrl: '{$res.us_headImg}', // 分享图标
			  success: function () {
				var uid = $.trim($('#uid').val());
				// 用户确认分享后执行的回调函数
				$.ajax({
					type:'post',
					url: "{:url('Index/shareClick')}",
					data:{us_id: uid},
					dataType: 'json',
					success: function(data){                
						if(data.status == 1){
							mui.toast(data.msg,{ duration:'long', type:'div'});
							//临时追加
							var num = Number($(".shareText").text()) + 1; 
							$(".shareText").text(num); 
						}else{
							mui.toast(data.msg,{ duration:'long', type:'div'}); 
						}                
					},
					error:function(request){                
						mui.toast('系统错误！',{ duration:'long', type:'div' }) 
					},
				});
			  },
			  cancel: function () {
			        // 用户取消分享后执行的回调函数
			  }
			});
            //分享给朋友
			wx.onMenuShareAppMessage({
			  title: '{$res.us_trueName}的名片', // 分享标题
			  desc: '', // 分享描述
			  link: '', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一�?
			  imgUrl: '{$res.us_headImg}', // 分享图标
			  type: '', // 分享类型,music、video或link，不填默认为link
			  dataUrl: '', // 如果type是music或video，则要提供数据链接，默认为空
			  success: function () {
				var uid = $.trim($('#uid').val());
				// 用户确认分享后执行的回调函数
				$.ajax({
					type:'post',
					url: "{:url('Index/shareClick')}",
					data:{us_id: uid},
					dataType: 'json',
					success: function(data){                
						if(data.status == 1){
							mui.toast(data.msg,{ duration:'long', type:'div'});
							//临时追加
							var num = Number($(".shareText").text()) + 1; 
							$(".shareText").text(num); 
						}else{
							mui.toast(data.msg,{ duration:'long', type:'div'}); 
						}                
					},
					error:function(request){                
						mui.toast('系统错误！',{ duration:'long', type:'div' }) 
					},
				});
			  },
			  cancel: function () {
				// 用户取消分享后执行的回调函数
			  }
			});
			//分享QQ
			wx.onMenuShareQQ({
			  title: '{$res.us_trueName}的名片', // 分享标题
			  desc: '',// 分享描述
			  link: '', // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一�?
			  imgUrl: '{$res.us_headImg}', // 分享图标
			  success: function () {
				// 用户确认分享后执行的回调函数
			  },
			  cancel: function () {
				// 用户取消分享后执行的回调函数
			  }
			});
		});
        //错误信息
		wx.error(function (res) {
		  console.log(res)
		  alert('签名错误')
		});
	</script>
</head>

<body>
    <header class="mui-bar mui-bar-nav">
        <button type="button" class="mui-left mui-action-back mui-btn  mui-btn-link mui-btn-nav mui-pull-left">
            <span class="mui-icon mui-icon-left-nav" onclick="window.location.href='{:url('Index/index')}'"></span>
        </button>
        <h1 class="mui-center mui-title">名片</h1>
    </header>
    <div class="show">
        <div style="width: 100%; height: 2.7rem;margin: 0 auto;background: #3E94EB;z-index: -1;"></div>
        <table class="myCard" style="margin-top: -1.6rem;">
            <tr>
                <td>
					<input type="hidden" name="uid" id="uid" value="{$res.us_id}" />
                    <span class="name">{$res.us_trueName}</span><br/>
                    <span class="unit">{$res.us_company}</span><br/>
                </td>
                <td><img src="{$res.us_headImg}" alt=""/></td>
            </tr>
            <tr>
                <td colspan="2">
                    <div style="width: 2.22rem; height: 0.01rem; background: #999999;margin: 0 0 0.3rem 0.75rem;"></div>
                    <span class="phone">联系电话：{$res.us_phone}</span><br/>
                    <span class="address">地址：{$res.us_address}</span>
                </td>
            </tr>            
        </table>
    </div>

    <div class="mui-wrapper" style="{eq name='res.c_public' value='2'}display: block;{else/}display: none;{/eq}">
        <div class="mui-table-view-cell">
            {eq name="res.c_forward" value="1"} <!-- 是否允许分享 -->
            <span class="mui-pull-right" >
                <span class="iconfont">&#xe71f;</span>分享 <span class="shareText">{$res.us_share}</span>
            </span>
            {/eq}
            <span class="mui-pull-right" onclick="collect({$res.us_id})">
                <span class="iconfont">&#xe605;</span>收藏 <span class="collectText">{$res.c_collection}</span>
            </span>
            <span class="mui-pull-right">
                <span class="iconfont">&#xe606;</span>浏览 {$res.c_popularity}
            </span>
        </div>

        <table class="cardInfo">
            <tr><td colspan="2"><p>名片信息展示</p></td></tr>
            <tr><td>姓名</td><td>{$res.us_trueName}</td></tr>
            <tr><td>性别</td><td>{eq name="$res.us_sex" value="1"}男{else/}女{/eq}</td></tr>
            <tr><td>手机</td><td onclick="window.location.href='tel:{$res.us_phone}'">{$res.us_phone}</td></tr>
            <tr><td>座机</td><td onclick="window.location.href='tel:{$res.us_landline}'">{$res.us_landline}</td></tr>
            <tr><td>单位</td><td>{$res.c_companyName}</td></tr>
            <tr><td>链接</td><td onclick="window.location.href='{$res.us_myurl}'">{$res.us_myurl}</td></tr>
            <tr><td>地址</td><td>{$res.c_address}</td></tr>
            <tr><td colspan="2">&nbsp;</td></tr>
        </table>          
    </div>

    {include file="public/indexFooter" /}

</body>
<script src="__static__/js/jquery.min.js"></script>
<script type="text/javascript">
    //收藏名片
    function collect(id){
        $.ajax({
            type:'post',
            url: "{:url('Index/collectClick')}",
            data:{us_id:id},
            dataType: 'json',
            success: function(data){                
                if(data.status == 1){
                    mui.toast(data.msg,{ duration:'long', type:'div'});
                    //临时追加
                    var num = Number($(".collectText").text()) + 1; 
                    $(".collectText").text(num); 
                }else{
                    mui.toast(data.msg,{ duration:'long', type:'div'}); 
                }                
            },
            error:function(request){                
                mui.toast('系统错误！',{ duration:'long', type:'div' }) 
            },
        });
    }

    //分享
    function share(id){
        $.ajax({
            type:'post',
            url: "{:url('Index/shareClick')}",
            data:{us_id:id},
            dataType: 'json',
            success: function(data){                
                if(data.status == 1){
                    mui.toast(data.msg,{ duration:'long', type:'div'});
                    //临时追加
                    var num = Number($(".shareText").text()) + 1; 
                    $(".shareText").text(num); 
                }else{
                    mui.toast(data.msg,{ duration:'long', type:'div'}); 
                }                
            },
            error:function(request){                
                mui.toast('系统错误！',{ duration:'long', type:'div' }) 
            },
        });
    }   
</script>

</html>